package Test;

import java.util.*;

public class dp1 {

    public static void main(String[] args) {
        int []arr={1,2,2,46,1,2,1,564,6456,32,11};
        HashSet<Integer>set=new HashSet<>();
        for (int i = 0; i < arr.length ; i++) {
            if(!set.contains(arr[i])){
                set.add(arr[i]);
            }else {
                System.out.println(arr[i]);
                break;
            }
        }
    }

    public static void main7(String[] args) {
        HashMap<String,Integer>hashMap=new HashMap<>();
    }


    public static void main5(String[] args) {
        TreeMap<String,Integer>map=new TreeMap<>();
        map.put("abc",21);
        map.put("abc",31);
        map.put("aba",2);
        map.put("ada",1);
       Set<String>set1=map.keySet();
        for (String set:set1) {
            System.out.print(set+"  ");
        }
        System.out.println();
      Collection<Integer>cl=map.values();
        for (Integer in:cl) {
            System.out.print(in+" ");
        }


    }



    public static void main4(String[] args) {
        TreeSet<String>set=new TreeSet<>();
        set.add("abc");
        set.add("abcd");
        set.add("abcd");
        set.add("ab");


        Object[]arr=set.toArray();
        for (Object e:arr) {
            System.out.print(e+" ");
        }


      /**  System.out.println(set.size());
set.remove("dad");

        Iterator<String>it= set.iterator();
while (it.hasNext()){
    System.out.println(it.next()+"  ");
}
        System.out.println();
        System.out.println(set.isEmpty());
set.remove("da");

**/

       //System.out.println(set.contains("dad"));
        //set.clear();
    }



    public static void main3(String[] args) {
        TreeMap<String,Integer>map=new TreeMap<>();
        map.put("abc",12);
        map.put("ab",22);
        map.put("ac",112);
        map.put("a",142);
        System.out.println(map.get("ac"));

        int v=map.get("abc");
        System.out.println(v);


        int v1=map.getOrDefault("dgah",882);
        System.out.println(v1);

        Integer v3=map.get("83hf");
        System.out.println(v3);


        map.put("abc",632);
Set<Map.Entry<String,Integer>>set=map.entrySet();
        for (Map.Entry<String,Integer> st:set) {
            System.out.println("key=="+st.getKey()+"  val=="+st.getValue());
        }



     //   map.remove("abc");

       // System.out.println(map.containsKey("adasbc"));
        //System.out.println(map.containsValue(22));
/**
        Set<String>set=map.keySet();
        for (String str:set) {
            System.out.print(str+" ");
        }
        System.out.println();
Collection<Integer>cl= map.values();
        for (Integer in:cl) {
            System.out.print(in+" ");
        }
        System.out.println();
Set<Map.Entry<String,Integer>>entry=map.entrySet();
        for (Map.Entry<String,Integer> en:entry) {
            System.out.println("key="+en.getKey()+"  val="+en.getValue());
        }
**/
    }



    public static void main2(String[] args) {
        TreeSet<String>set=new TreeSet<>();
        set.add("aaa");
        set.add("vvv");
        set.add("v12v");
        set.add("v21");
        set.add("v53");
        set.add("12f");


      Iterator<String>it= set.iterator();

    }




    public static void main1(String[] args) {
        TreeMap<String,Integer>treeMap=new TreeMap<>();
        treeMap.put("abc",3);
        treeMap.put("hello",4);
        treeMap.put("world",2);
treeMap.put("abc",5);

        Set<String>set=treeMap.keySet();

        Set<Map.Entry<String,Integer>>entrySet=treeMap.entrySet();
        for (Map.Entry<String,Integer>entry:entrySet) {
            System.out.println("Key:"+entry.getKey()+" val:"+entry.getValue());
        }


      //  int val=treeMap.getOrDefault("hellsad",100);
        //System.out.println(val);
        //System.out.println(treeMap.get("hello2"));


    //  int val=  treeMap.remove("abc");

      //  System.out.println(val);
    }
}
